package com.atguigu.test.mvc.view;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.web.servlet.View;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author zp
 * @version 1.0
 * @description: 自定义视图对象
 * @date 2023/1/17 19:18
 */
public class MyView implements View {
    @Override
    public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
        System.out.println(model);
        ObjectMapper mapper = new ObjectMapper();
        String s = mapper.writeValueAsString(model);
        response.getWriter().println(s);
    }
}
